# vim: set filetype=py
 
Import('dev source_path')

env, target, sources = dev.prepare_build(source_path, 'DCPlusPlus', precompiled_header = 'stdafx')

if env['CC'] == 'cl': # MSVC
	if dev.mode == 'debug':
		env.Prepend(LIBS = ['ssleay32d', 'libeay32d'])
	else:
		env.Prepend(LIBS = ['ssleay32', 'libeay32'])
else:
	env.Prepend(LIBS = ['ssl', 'crypto'])
	env.Append(CPPPATH = ['#/htmlhelp/include/'])
	env.Append(LIBPATH = ['#/htmlhelp/lib/'])
env.Append(LIBS = ['comctl32', 'ws2_32', 'ole32', 'gdi32', 'comdlg32', 'iphlpapi', 'winmm', 'shlwapi', 'htmlhelp', 'oleaut32', 'uuid'])
env.Append(CPPPATH = ['#/openssl/include', '#/miniupnpc', '#/dwt/include', '#/'])
openssl_lib = '#/openssl/lib/'
if env['arch'] != 'x86':
	openssl_lib += env['arch'] + '/'
env.Append(LIBPATH = [openssl_lib])

if env['RC'] == 'rc': # MSVC
	env.Append(RCFLAGS = ['/dNO_MANIFEST'])
	manifest_arch = env['arch']
	if manifest_arch == 'x64':
		manifest_arch = 'amd64'
	env.Append(LINKFLAGS = ["/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls'\
 version='6.0.0.0' processorArchitecture='" + manifest_arch + "' publicKeyToken='6595b64144ccf1df'\
 language='*'"])
elif env['RC'].find('windres') != -1: # MinGW
	env.Append(RCFLAGS = ['-D' + env['arch']])
else:
	print 'Unknown resource compiler.'
	Return()
res = env.RES(dev.get_sources(source_path, '*.rc'))
env.Depends(res, 'resource.h')

headers=dev.get_sources(source_path, "*.h")
dev.i18n(source_path, env, [sources,headers], 'dcpp-win32')

ret = env.Program(target, [sources, res, dev.client, dev.zlib, dev.bzip2, dev.miniupnpc, dev.dwt, dev.intl])
Return('ret')
